package me.yuxiaoyao.lock.interceptor;

import org.springframework.util.function.SingletonSupplier;

/**
 * @author kerryzhang on 2020/12/24
 */


public abstract class AbstractDistributedLockInvoker {
    protected SingletonSupplier<ErrorHandler> errorHandler;


    protected AbstractDistributedLockInvoker() {
        this.errorHandler = SingletonSupplier.of(DefaultErrorHandler::new);
    }

    protected AbstractDistributedLockInvoker(ErrorHandler errorHandler) {
        this.errorHandler = SingletonSupplier.of(errorHandler);
    }

    public void setErrorHandler(ErrorHandler errorHandler) {
        this.errorHandler = SingletonSupplier.of(errorHandler);
    }

    public ErrorHandler getErrorHandler() {
        return this.errorHandler.obtain();
    }

}
